package ir.types;

import ir.types.datatypes.DataType;

import java.util.ArrayList;

public class FunctionType extends Type {
    private final DataType returnType;
    private final ArrayList<DataType> paramTypes;

    public FunctionType(DataType returnType, ArrayList<DataType> paramTypes) {
        this.returnType = returnType;
        this.paramTypes = paramTypes;
    }

    public DataType getReturnType() {
        return returnType;
    }

    public ArrayList<DataType> getParamTypes() {
        return paramTypes;
    }

    @Override
    public String toString() {
        StringBuilder sb = new StringBuilder();
        sb.append(returnType).append(" (");
        for (int i = 0; i < paramTypes.size(); i++) {
            sb.append(paramTypes.get(i));
            if (i != paramTypes.size() - 1) {
                sb.append(", ");
            }
        }
        sb.append(")*");
        return sb.toString();
    }
}
